package com.fileDemo;

import org.junit.Test;

import java.io.FileReader;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: FENGYiMing
 * @Date: 2024/04/08/15:16
 * @Description:
 */
public class FileReader01 {
    public static void main(String[] args) throws IOException {
        FileReader fileReader = new FileReader("e:/a.txt");
        int data = 0;
        while ((data = fileReader.read()) != -1) {
            System.out.print((char) data);
        }
        fileReader.close();
    }

    @Test
    public void readFile() throws IOException {
        FileReader fileReader = new FileReader("e:/a.txt");
        int data = 0;
        char[] buf = new char[8];
        while ((data = fileReader.read(buf)) != -1) {
            System.out.print(new String(buf, 0, data));
        }
        fileReader.close();

    }
}
